<template>
  <div class="home">
      <h2>vuex 尝试</h2>
      <div>
          <p>{{ $store.state.a }}</p>
          <p>{{ $store.getters.doubleA }}</p>
          <p>{{ $store.getters.tripleA }}</p>
      </div>
      <div>
          <button @click="$store.commit('addA')">a++</button>
          <button @click="$store.commit('reduceA')">a--</button>
          <button @click="$store.commit('updateA',10)">更新A</button>
      </div>

  </div>
</template>

<script>
// @ is an alias to /src

//  把store实例注入到Vue根实例 -> Vue下的所有组件(应用)都可以通过$store访问
export default {
  name: 'HomeView',
  mounted(){
    console.log("当前实例",this)
    console.log("当前实例下的store实例",this.$store)
  },
}
</script>
